//
//  YLUserModel.m
//  Yilong
//
//  Created by DisCover on 2021/6/22.
//

#import "YLUserModel.h"
static YLUserModel* _instance = nil;


@implementation YLUserModel
- (instancetype)init{

    if (self = [super init]) {
    
    }

    return self;

}


- (void)setUUIDArray:(NSArray *)UUIDArray{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:UUIDArray forKey:@"UUIDArray"];
    [userdefault synchronize];


}
- (NSArray *)UUIDArray{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSArray* key =  (NSArray*)[userdefault objectForKey:@"UUIDArray"];
    return key;

}

- (void)updateUUIDArray:(NSString*)uuid{
    NSMutableArray *arr;
    
    if (self.UUIDArray == nil || self.UUIDArray.count == 0) {
        arr = [NSMutableArray array];
    }else{
        arr = [self.UUIDArray mutableCopy];
    }
    if (![arr containsObject:uuid]) {
        [arr addObject:uuid];
    }
    self.UUIDArray = [arr copy];
}


- (void)setSsKey:(NSData *)ssKey{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:ssKey forKey:@"ssKey"];
    [userdefault synchronize];
    
}
- (NSData*)ssKey{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSData* key =  (NSData*)[userdefault objectForKey:@"ssKey"];
    

    return key;
}
-(void)setDeviceKey:(NSData *)deviceKey{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:deviceKey forKey:@"deviceKey"];
    [userdefault synchronize];
    
}
- (NSData*)deviceKey{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSData* key =  (NSData*)[userdefault objectForKey:@"deviceKey"];
    

    return key;
}
- (void)setUserId:(NSString *)userId{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:userId forKey:@"userId"];
    [userdefault synchronize];

}
- (NSString*)userId{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"userId"];
    return key;
}

- (NSString *)reUserId {
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"userId"];
    NSString* changeKey = @"";
    if (key.length > 10) {
        changeKey =  [key substringFromIndex:key.length-10];
    }
    return changeKey;
}



- (void)setUserName:(NSString *)userName{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:userName forKey:@"userName"];
    [userdefault synchronize];
}
- (NSString *)userName{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"userName"];
    return key;

}
- (void)setToken:(NSString *)token{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:token forKey:@"token"];
    [userdefault synchronize];

}
- (NSString *)token{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"token"];
    return key;

}
- (void)setPassWord:(NSString *)passWord{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:passWord forKey:@"passWord"];
    [userdefault synchronize];

}
- (NSString *)passWord{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"passWord"];
    return key;

}
- (void)setLockId:(NSString *)lockId{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:lockId forKey:@"lockId"];
    [userdefault synchronize];

}
- (NSString*)lockId{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"lockId"];
    return key;

}

- (void)setVersion:(NSString *)version{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:version forKey:@"version"];
    [userdefault synchronize];

}
- (NSString *)version{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"version"];
    return key;

}

 

- (void)setSiteUrl:(NSString *)siteUrl{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:siteUrl forKey:@"siteUrl"];
    [userdefault synchronize];

}
- (NSString *)siteUrl{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"siteUrl"];
    return key;

}

- (void)setOrgProfile:(NSString *)orgProfile{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:orgProfile forKey:@"orgProfile"];
    [userdefault synchronize];

}
- (NSString *)orgProfile{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"orgProfile"];
    return key;

}



- (void)setServicePhone:(NSString *)servicePhone{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:servicePhone forKey:@"servicePhone"];
    [userdefault synchronize];

}
- (NSString *)servicePhone{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"servicePhone"];
    return key;

}



- (void)setExpire:(NSString *)expire{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:expire forKey:@"expire"];
    [userdefault synchronize];

}
- (NSString *)expire{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"expire"];
    return key;

}



- (void)setCooperativePhone:(NSString *)cooperativePhone{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:cooperativePhone forKey:@"cooperativePhone"];
    [userdefault synchronize];

}
- (NSString *)cooperativePhone{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"cooperativePhone"];
    return key;

}






- (void)setPhone:(NSString *)phone{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:phone forKey:@"phone"];
    [userdefault synchronize];

}
- (NSString *)phone{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"phone"];
    return key;

}
- (void)setTouchID:(NSString *)touchID{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setValue:touchID forKey:@"touchID"];
    [userdefault synchronize];

}
- (NSString *)touchID{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    NSString* key =  (NSString*)[userdefault objectForKey:@"touchID"];
    return key;

}
- (void)setRandom1:(uint32_t)random1{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setInteger:random1 forKey:@"random1"];
    [userdefault synchronize];

}
- (uint32_t)random1{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    uint32_t key =  (uint32_t)[userdefault integerForKey:@"random1"];
    return key;

}
- (void)setRandom2:(uint32_t)random1{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    [userdefault setInteger:random1 forKey:@"random2"];
    [userdefault synchronize];

}
- (uint32_t)random2{
    NSUserDefaults*userdefault = [NSUserDefaults standardUserDefaults];
    uint32_t key =  (uint32_t)[userdefault integerForKey:@"random2"];
    return key;

}

- (void)loginOut{
    self.userId = @"";
    self.userName = @"";
    self.token = @"";
    self.touchID = @"";
    

    
}


+(instancetype)shareInstance{
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        
        _instance = [[YLUserModel alloc]init];
        
    });
    
    return _instance;
    
}

@end


